#使用的编译器
include user.mk
CC = sdcc

#传入的c文件名
TARGET_ARCH = my


CFLAGS=$(C_INCLUDES)
cname = my
proj = output
tmpdir = tmp
usrdir = usr
all : $(tmpdir)/$(cname).ihx $(tmpdir)/$(cname).hex $(tmpdir)/$(cname).bin
OBJECTS = $(addprefix $(tmpdir)/,$(notdir $(C_SOURCES:.c=.rel)))
vpath %.c $(sort $(dir $(C_SOURCES)))
$(tmpdir)/%.rel: %.c Makefile | $(tmpdir) 
	$(CC) -c $(CFLAGS) $< -o $@
$(tmpdir)/$(cname).ihx: $(OBJECTS)
	$(CC) $^ -o $(tmpdir)/$(cname).ihx
$(tmpdir)/%.hex: $(tmpdir)/%.ihx | $(tmpdir)
	packihx $< $@ > $(tmpdir)/$(cname).hex
$(tmpdir)/%.bin:$(tmpdir)/%.hex
	sdobjcopy -I ihex -O binary $^ $@
$(tmpdir):
	mkdir $@
.PHONY : clean
clean :
	-rm -r $(tmpdir)

	
